/**
 * 
 */
package de.hft_stuttgart.dsa.ctt.processing.yuruz;

import de.hft_stuttgart.dsa.ctt.model.Course;
import de.hft_stuttgart.dsa.ctt.model.CourseAssignmentMatrix;
import de.hft_stuttgart.dsa.ctt.model.Period;
import de.hft_stuttgart.dsa.ctt.model.ProblemInstance;
import de.hft_stuttgart.dsa.ctt.model.UnavailabilityConstraint;

/**
 * @author Ali Yuruz
 */
public class ConstraintChecker implements IChecker {
	private ProblemInstance problemInstance;

	public ConstraintChecker(ProblemInstance pInstance) {
		this.problemInstance = pInstance;
	}

	@Override
	public boolean isAssignable(Course courseToCheck, CourseAssignmentMatrix assignmentMatrix, int slotToCheck) {

		for (UnavailabilityConstraint constraint : courseToCheck.getUnavailabilityConstraints()) {
			if (slotToCheck == Period.getCalculatedPeriod(problemInstance.getPeriodsPerDay(), constraint.getPeriodOfDay(), constraint.getDayOfWeek())) {
				return false;
			}
		}

		return true;
	}
}
